home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #2 / Amiga Plus CD - 1999 - No. 2.iso / System-Boost / Workbench / ToolManager / Source / Converter / image.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  2KB  |  83 lines

  1. /*
  2.  * image.c  V3.1
  3.  *
  4.  * ToolManager old preferences converter for Image Objects
  5.  *
  6.  * Copyright (C) 1990-98 Stefan Becker
  7.  *
  8.  * This source code is for educational purposes only. You may study it
  9.  * and copy ideas or algorithms from it for your own projects. It is
  10.  * not allowed to use any of the source codes (in full or in parts)
  11.  * in other programs. Especially it is not allowed to create variants
  12.  * of ToolManager or ToolManager-like programs from this source code.
  13.  *
  14.  */
  15.  
  16. #include "converter.h"
  17.  
  18. /* Local data */
  19. static struct MinList IDList;
  20. static struct StandardDATAChunk sdc;
  21.  
  22. /* Old Prefs stuff */
  23. struct ImagePrefsObject {
  24.                          ULONG ipo_StringBits;
  25.                         };
  26. #define IMPO_NAME (1L << 0)
  27. #define IMPO_FILE (1L << 1)
  28.  
  29. /* Initialize Image ID list */
  30. void InitImageIDList(void)
  31. {
  32.  NewList((struct List *) &IDList);
  33. }
  34.  
  35. /* Free Image ID list */
  36. void FreeImageIDList(void)
  37. {
  38.  FreeIDList(&IDList);
  39. }
  40.  
  41. /* Find ID to corresponding Image name */
  42. ULONG FindImageID(const char *name)
  43. {
  44.  return(FindIDInList(&IDList, name));
  45. }
  46.  
  47. /* Conversion routine */
  48. #undef  DEBUGFUNCTION
  49. #define DEBUGFUNCTION ConvertImageConfig
  50. BOOL ConvertImageConfig(void *chunk, struct IFFHandle *iffh, ULONG id)
  51. {
  52.  struct ImagePrefsObject *ipo = chunk;
  53.  char                    *s   = (char *) (ipo + 1);
  54.  BOOL                     rc  = FALSE;
  55.  
  56.  IMAGE_LOG(LOG3(Entry, "Chunk 0x%08lx IFF Handle 0x%08lx ID 0x%08lx",
  57.                 chunk, iffh, id))
  58.  
  59.  /* Get name to create ID list entry */
  60.  if ((ipo->ipo_StringBits & IMPO_NAME) && AddIDToList(&IDList, s, id)) {
  61.  
  62.   /* Initialize fixed data */
  63.   sdc.sdc_ID    = id;
  64.   sdc.sdc_Flags = 0;
  65.  
  66.   /* Create new config entry */
  67.   rc = (PushChunk(iffh, ID_TMIM, ID_FORM, IFFSIZE_UNKNOWN) == 0) &&
  68.        (PushChunk(iffh, 0,       ID_DATA, IFFSIZE_UNKNOWN) == 0) &&
  69.        (WriteChunkBytes(iffh, &sdc, sizeof(struct StandardDATAChunk))
  70.          == sizeof(struct StandardDATAChunk)) &&
  71.        (PopChunk(iffh) == 0) &&
  72.        (((ipo->ipo_StringBits & IMPO_NAME)    == 0) ||
  73.         (s = ConvertConfigString(s, iffh, ID_NAME))) &&
  74.        (((ipo->ipo_StringBits & IMPO_FILE) == 0) ||
  75.         (s = ConvertConfigString(s, iffh, ID_FILE))) &&
  76.        (PopChunk(iffh) == 0)  ;
  77.  }
  78.  
  79.  IMAGE_LOG(LOG1(Result, "%ld", rc))
  80.  
  81.  return(rc);
  82. }
  83.